//表单
const Sequelize = require('sequelize')
const { mySequelize } = require('../config/index')
const User = require('./User') 
const Projects = require('./Projects')



const Forms = mySequelize.define('forms', {
 form_id: {
    type: Sequelize.INTEGER(11),
    allowNull: false,
    primaryKey: true,
    autoIncrement: true,
  },
  user_id: {
    type: Sequelize.INTEGER(11),
    allowNull: false,
    foreignKey: true,
  },
  project_id: {
    type: Sequelize.INTEGER(11),
    allowNull: false,
    foreignKey: true,
  },
  status: {
    type: Sequelize.INTEGER,
    allowNull: false,
    comment: "0-进行中,1-已通过,2-已拒绝",
  },
  reason:{
    type: Sequelize.STRING(255),
    allowNull: true,
  }
}, {
  freezeTableName: true,
  timestamps: false,
  tableName: 'forms',
})

Forms.belongsTo(User, { foreignKey: 'user_id', targetKey: 'user_id', as: 'userDetail' })
Forms.belongsTo(Projects, { foreignKey: 'project_id', targetKey: 'project_id', as: 'projectDetail' })

module.exports = Forms